﻿#include "stdafx.h"
#include "QSSDemo.h"
#include "QMyMessageBox.h"
#include "QSubDialog.h"
#if defined(_MSC_VER) && (_MSC_VER >= 1600)  
#pragma execution_character_set("utf-8")
#endif 


QSSDemo::QSSDemo(QWidget *parent)
	: QFramelessDialog(parent)
	, m_NewQssAction(new QAction("新建QSS", this))
	, m_OpenQssAction(new QAction("打开QSS", this))
	, m_SetColorAction(new QAction("设置颜色", this))
	, m_SaveQssAction(new QAction("保存", this))
	, m_SaveAsQssAction(new QAction("另存为", this))
	, m_HelpAction(new QAction("帮助", this))
	, m_AboutAction(new QAction("关于", this))
{
	ui.setupUi(this);
	FRAMELESS_MAIN_DIALOG_INIT();

	QString qss;
	QFile qssFile(":/Skin/skin.qss");
	qssFile.open(QFile::ReadOnly);
	if (qssFile.isOpen())
	{
		qss = QLatin1String(qssFile.readAll());
		qApp->setStyleSheet(qss);
		qssFile.close();
	}

	m_menuFile = new QMenu(QStringLiteral("文件(&F)"));
	m_menuFile->addAction(m_NewQssAction);
	m_menuFile->addAction(m_SetColorAction);
	/*	m_menuFile->addAction(m_OpenQssAction);*/
	m_menuFile->addAction(m_SaveQssAction);
	/*	m_menuFile->addAction(m_SaveAsQssAction);*/

	m_menuHelp = new QMenu(QStringLiteral("帮助(&H)"));
	m_menuHelp->addAction(m_HelpAction);
	m_menuHelp->addAction(m_AboutAction);

	m_MenuBar = new QMenuBar(this);
	m_MenuBar->addMenu(m_menuFile);
	m_MenuBar->addMenu(m_menuHelp);

	QHBoxLayout* horizontalLayout = new QHBoxLayout(ui.widget_menu);
	horizontalLayout->setSpacing(0);
	horizontalLayout->setContentsMargins(1, 0, 1, 0);
	horizontalLayout->addWidget(m_MenuBar);

	connect(ui.pushButton_MsgBox, SIGNAL(clicked()), this, SLOT(sltClickMsgBox()));
	connect(ui.pushButton_SubDialog, SIGNAL(clicked()), this, SLOT(sltClickSubDialog()));

	
}

QSSDemo::~QSSDemo()
{

}

void QSSDemo::sltClickSubDialog()
{
	QSubDialog dlg(this);
	dlg.exec();
}
void QSSDemo::sltClickMsgBox()
{
	QMyMessageBox::information(this, "QSS设计器太好用了，超赞！！！");
}
